package com.minimalist.lindi.mapper;

import com.minimalist.common.entity.lindi.po.LindiEnterpriseRegistration;
import com.minimalist.common.entity.lindi.vo.enterpriseregistration.LindiEnterpriseRegistrationQueryVO;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;

/**
 * 林地指标交易平台_企业注册表 映射层。
 *
 * @author 11987
 * @since 2025-03-31
 */
public interface LindiEnterpriseRegistrationMapper extends BaseMapper<LindiEnterpriseRegistration>{


    /**
     * 根据企业注册信息ID查询
     *
     * @param enterpriseRegistrationId 企业注册信息ID
     * @return 企业注册信息对象
     */
    default LindiEnterpriseRegistration selectEnterpriseRegistrationByEnterpriseRegistrationId(
            Long enterpriseRegistrationId){
        return selectOneByQuery(QueryWrapper.create()
                .eq(LindiEnterpriseRegistration::getEnterpriseRegistrationId
                        , enterpriseRegistrationId));
    }

    /**
     * 根据企业注册信息ID更新
     *
     * @param lindiEnterpriseRegistration 企业注册信息对象
     */
    default void updateEnterpriseRegistrationByEnterpriseRegistrationId(
            LindiEnterpriseRegistration lindiEnterpriseRegistration){
        updateByQuery(lindiEnterpriseRegistration, QueryWrapper.create()
                .eq(LindiEnterpriseRegistration::getEnterpriseRegistrationId
                        , lindiEnterpriseRegistration.getEnterpriseRegistrationId()));
    }

    /**
     * 分页查询
     *
     * @param queryVO 查询参数
     * @return 分页结果
     */
    default Page<LindiEnterpriseRegistration> selectPageEnterpriseRegistrationList(LindiEnterpriseRegistrationQueryVO queryVO){
        return paginate(queryVO.getPageNum(), queryVO.getPageSize(),
                QueryWrapper.create()
                        .eq(LindiEnterpriseRegistration::getStatus
                                , queryVO.getStatus())
                        .like(LindiEnterpriseRegistration::getEnterpriseName
                                , queryVO.getEnterpriseName())
        );
    }

    /**
     * 根据企业注册信息ID删除
     *
     * @param enterpriseRegistrationId 企业注册信息ID
     */
    default void deleteEnterpriseRegistrationByEnterpriseRegistrationId(Long enterpriseRegistrationId){
        deleteByQuery(QueryWrapper.create()
                .eq(LindiEnterpriseRegistration::getEnterpriseRegistrationId
                        , enterpriseRegistrationId));
    }
}
